package com.zy.serviceimpl;

import com.zy.mapper.UserMapper;
import com.zy.pojo.User;
import com.zy.service.UserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
@Service("userService")  //创建service对象，起名
public class UserServiceImpl implements UserService{
    //自动装配（根据名字，找到这个dao接口）
    @Resource
    private UserMapper userMapper;

    @Override
    public List<User> getUserList() {
        return userMapper.selectList(null);
    }

    @Override
    public User getUserId(Integer id) {
        return userMapper.selectById(id);
    }

    @Override
    public void add(User user) {
        userMapper.insert(user);
    }

    @Override
    public void update(User user) {
        userMapper.updateById(user);
    }

    @Override
    public void delete(Integer id) {
        userMapper.deleteById(id);
    }
}
